package com.fit.WatchShop.beans;

import java.util.LinkedList;
import java.util.List;

import com.fit.WatchShop.interfaces.*;
import com.fit.WatchShop.service.BuyUniqueID;
import com.fit.WatchShop.service.Buys;


public class BuyBean implements Buy {
	
	private String id;
	private Buyer buyer;
	private WatchWorker watchWorker;
	public List<Watch> watch;
	

	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id = id;
	}

	public Buyer getBuyer() {
		return buyer;
	}
	
	public void setBuyer(Buyer buyer) {
		this.buyer = buyer;
	}

	public WatchWorker getWatchWorker() {
		return watchWorker;
	}
	
	public void setWatchWorker(WatchWorker watchWorker) {
		this.watchWorker = watchWorker;
	}

	public List<Watch> getWatch() {
		return watch;
	}

	public void setWatch(List<Watch> watch) {
		this.watch = watch;
	}

	public void executeBuyCreation(Buyer buyer, WatchWorker watchWorker, 
			Watch watch, Buys buys) {
	
			this.setId(BuyUniqueID.getBuyUniqueID());
			this.setWatchWorker(watchWorker);
			this.setBuyer(buyer);
			
			List<Watch> l = new LinkedList<Watch>();
			l.add(watch);
			
			this.setWatch(l);
					
			buyer.getBuy().add(this);
			watch.getBuy().add(this);
			buyer.getBuy().add(this);
			
			buys.save(this);
		}
		
	}
	

